<template>
    <section class="intelligent-content-bg overflowYAll">
        <div class="intelligent-content-box">
            <el-form :inline="true" >
                <el-form-item >
                    <el-button type="primary" @click="dialogAdds('注册字典')">
                        +注册字典
                    </el-button>
                </el-form-item>
                <el-form-item >
                    <dictionary-tree
                        @select="select"
                        :parentOptions="parentOptions"
                    >
                    </dictionary-tree>
                </el-form-item>
            </el-form>
            <el-row>
                <el-col>
                    <dictionary-list
                        :tableData="tableData"
                        @edit="dialogEdits"
                        :pageTotal="pageTotal"
                        @listSearch="listSearch"
                    >
                    </dictionary-list>
                </el-col>
            </el-row>
            <el-dialog
                :title="dialogTitle"
                :visible.sync="dialogVisible"
                v-if="dialogVisible"
                width="50%"
                class="diy-dialog"
                :append-to-body="true"
            >
                <dialog-box
                    :dialogAdd="dialogAdd"
                    :dialogEdit="dialogEdit"
                    :parentOptions="parentOptions"
                    :singeOption="singeOption"
                    @cancel="cancel"
                    @listSearch="listSearch"
                >
                </dialog-box>
            </el-dialog>
        </div>
    </section>
</template>

<script>
    import {
        computedPostSmDictionaryTreeSearch,
        computedPostSmDictionaryTypeSearch,
        computedDictionarySearch,
    } from "./css_js_img/computedSmDictionaryController"
    import dictionaryTree from "./components/dictionaryTree"
    import dictionaryList from "./components/dictionaryList"
    import dialogBox from "./components/dialogBox"
    export default {
        data(){
            return {
                tableData: [],  //类型列表
                dialogTitle: "",    
                dialogVisible: false,
                dialogAdd: false,   //显示添加界面
                dialogEdit: false,  //显示编辑界面
                parentOptions: [],   //根项目
                singeOption: {},    //字段修改
                paramType: "info_type",   //字段类型
                pageNum: 1,
                pageTotal:10,
            }
        },
        components:{
            dictionaryTree,
            dictionaryList,
            dialogBox,
        },
        mounted(){
            computedPostSmDictionaryTreeSearch(this);
            computedPostSmDictionaryTypeSearch(this,'info_type',1)  //business_type  
        },
        methods: {
            dialogAdds(title){
                this.dialogVisible = true;
                this.dialogTitle = title;
                this.dialogAdd = true;
                this.dialogEdit = false;
            },
            dialogEdits(row){
                this.dialogVisible = true;
                this.dialogTitle = "修改字典";
                this.dialogAdd = false;
                this.dialogEdit = true;
                computedDictionarySearch(this,row.id,row.type)
            },
            cancel(param){
                this.dialogVisible = param;
            },
            listSearch(pageNo){
                computedPostSmDictionaryTypeSearch(this,this.paramType,pageNo);
                this.dialogVisible = false;
            },
            select(param){
                computedPostSmDictionaryTypeSearch(this,param,1)
                this.paramType = param;
            },
        },
    }
</script>